function js_main1(nums) {
  const len = nums.length;
  if (len < 2) return len;
  let count = 0;
  for (let i = 1; i < len; i++) {
    if (nums[count] !== nums[i]) {
      // 优化?处理器在处理相同数据赋值时是否会直接跳过不执行?
      // if (i > count) {
      //   nums[count + 1] = nums[i];
      // }
      nums[count + 1] = nums[i];
      count += 1;
    }
  }
  return count + 1;
}

const test1 = [1, 1, 2];
const len1 = js_main1(test1);
test1.length = len1;
console.log(len1, test1);

const test2 = [0, 0, 1, 1, 1, 2, 2, 3, 3, 4];
const len2 = js_main1(test2);
test2.length = len2;
console.log(len2, test2);
